'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 推送
 * @author sundbcn@gmail.com (sun debing)
 */

var pomelo = require('pomelo');
var eventType = require('../consts/eventType');
var channelUtil = require('../util/channelUtil');

/**
 * 发送消息
 */
exports.sendGlobalMessage = function (event_type, params, channel_name, cb) {
    // console.log('event_type:', event_type);
    if (!!pomelo.app) {
        var globalChannelService = pomelo.app.get('globalChannelService');
        globalChannelService.pushMessage(
            'connector',
            event_type,
            params,
            channel_name, {
                isPush: true
            }, cb);
    } else {
        if (!!cb) {
            cb();
        }
    }
};

/**
 * 发送消息
 * @return {[type]} [description]
 */
exports.sendStatusMessage = function (uids, event_type, params, cb) {
    if (!!pomelo.app) {
        var statusService = pomelo.app.get('statusService');
        statusService.pushByUids(
            uids,
            event_type,
            params,
            cb);
    } else {
        if (!!cb) {
            cb();
        }
    }
};
